home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5809 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.8 KB

  1. Path: news1.halcyon.com!chinook!jars
  2. From: jars@chinook.halcyon.com (Juan Rodriguez)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Visual C++ 4.0 DLL's for Win95 and Visual Basic 4.0
  5. Date: 6 Feb 1996 23:00:06 GMT
  6. Organization: Northwest Nexus, Inc. - Professional Internet Services
  7. Message-ID: <4f8mhm$lrn@news1.halcyon.com>
  8. References: <4f7ncl$998@infoserv.rug.ac.be>
  9. NNTP-Posting-Host: chinook.halcyon.com
  10.  
  11. In article <4f7ncl$998@infoserv.rug.ac.be>,
  12. Ward De Backer <ward.debacker@rug.ac.be> wrote:
  13. >When I develop applications for Windows, I normally use Visual Basic for the 
  14. >interface stuff and a DLL written with Visual C++ for the underlying 
  15. >algorithms. I have always developed applications for Windows 3.11.
  16. >Lastly, I tested the new Visual C++ 4.0 compiler for Windows 95. I wrote a 
  17. >32bit DLL with a simple testfunction in it. On the other side, I wrote a small 
  18. >program in Visual Basic that calls this subroutine. The First major difference 
  19. >I found was that the basic types of Visual Basic and Visual C++ are no longer 
  20. >compatible (i.e. consistent) because an "Integer" in VB is 16 bit wide and a 
  21. >standard int in VC++ is 32 bit wide in win95 (unless you declare it as int16). 
  22. >But this was not the major problem. When I tried to test my function by 
  23. >running my VB program, I couldn't get it to work by no means. Visual Basic 
  24. >either didn't find my DLL function or issued a "bad calling convention" 
  25. >message. Finally, I inspected my DLL executable with the dumpbin utility. To 
  26. >my surprise, I saw a totally different way of naming exported functions. 
  27. >Microsoft now uses so called "decorated names" for exported functions. This 
  28. >means that a function name is appended with a "@" and the number of bytes on 
  29. >the stack the function parameters occupy.
  30. >So far, so good. But the problem now is that Visual Basic doesn't recognise 
  31. >these decorated names in your DLL. As a consequence, you have to declare all 
  32. >the DLL functions with a decorated alias.
  33.  
  34. I don't really use Visual Basic v. 4.0; but I have it on my machine. I read
  35. the README file  in its directory, which explains how to build DLLs for it
  36. with Visual C++ v. 4.0; I built a small test case, and it worked. The file
  37. is called VB4DLL.TXT; it has a detalied description of the calling conven-
  38. tions. For example, it says you have to define NOMANGLE, and declare your
  39. exported functions as something like:
  40.  
  41. NOMANGLE short CCONV PassInteger(short intgr, short far *pintgr)
  42.    { ...
  43.  
  44.  
  45. Good luck!
  46.  
  47.  
  48.  
  49.  
  50. Juan Antonio Rodriguez-Sero; jars@halcyon.com;
  51. Lake Forest Park, WA 98155-2940, USA
  52. --------------------------------------------------------------------------
  53. More than any other time in history, mankind faces a crossroads. One path
  54. leads to despair and utter hopelessness. The other, to total extinction.
  55. Let us pray we have the wisdom to choose correctly.
  56.                                  Woody Allen, "My speech to the graduates" 
  57.